﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:WinChrome="clr-namespace:WinChrome" 
    xmlns:UI="clr-namespace:WinChrome.UI"
    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/WinChrome;component/UI/GlassResourceDictionary.xaml" />
        <ResourceDictionary Source="/WinChrome;component/UI/HistoryNavigatorStyles/ModernResourceDictionary.xaml" />
        <ResourceDictionary Source="/WinChrome;component/UI/VS2012ResourceDictionary.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <!-- Custom NavigationWindow UI -->
    <Style x:Key="ModernNavigationWindow" TargetType="{x:Type WinChrome:SearchableNavigationWindow}">
        <Setter Property="AllowsTransparency" Value="True"/>
        <Setter Property="WindowStyle" Value="None"/>
        <Setter Property="MinWidth" Value="400"/>
        <Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <shell:WindowChrome 
                    ResizeBorderThickness="6"
                    CaptionHeight="40"
                    CornerRadius="0"
                    GlassFrameThickness="0"/>
            </Setter.Value>
        </Setter>
        <Setter Property="WinChrome:VS2012.GlowColor" Value="{DynamicResource {x:Static SystemColors.HotTrackColorKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="WinChrome:SearchableNavigationWindow">
                    <Border x:Name="WindowGlowBorder" Style="{StaticResource GlowBorder}" WinChrome:VS2012.GlowBorder="True">
                        <Grid x:Name="ActualWindowRender" Background="{TemplateBinding Background}" ClipToBounds="True">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Grid x:Name="NonClientUI">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <UI:HistoryNavigator shell:WindowChrome.IsHitTestVisibleInChrome="True"         
                                                     Foreground="White"
                                                                BackCommand="NavigationCommands.BrowseBack" 
                                                                ForwardCommand="NavigationCommands.BrowseForward" 
                                                                CommandTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type NavigationWindow}}}" 
                                                                CommandParameter="{Binding RelativeSource={RelativeSource Self}}" Style="{StaticResource HistoryNavigatorModern}">
                                    <UI:HistoryNavigator.ItemsSource>
                                        <MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverter}" >
                                            <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type NavigationWindow}}" Path="BackStack"/>
                                            <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type NavigationWindow}}" Path="ForwardStack"/>
                                        </MultiBinding>
                                    </UI:HistoryNavigator.ItemsSource>
                                </UI:HistoryNavigator>

                                <TextBox x:Name="PART_SearchBox" Width="120"
                                    Height="23" Margin="0,3" VerticalAlignment="Top" 
                                         Grid.Column="2" 
                                         Text="{Binding SearchText, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type WinChrome:SearchableNavigationWindow}}, UpdateSourceTrigger=PropertyChanged}" />

                                <Grid Grid.Column="3" VerticalAlignment="Top"
                                      Height="29"
                                            		Width="{Binding WindowCaptionButtonsLocation.Width, Source={x:Static shell:SystemParameters2.Current}}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <Button Content="Minimize"
                                            			Command="{x:Static shell:SystemCommands.MinimizeWindowCommand}" 
                                            			shell:WindowChrome.IsHitTestVisibleInChrome="True" Style="{DynamicResource MinimizeButtonStyle}">
                                    </Button>
                                    <Button Content="Maximize" 
                                            			Grid.Column="1" Visibility="{TemplateBinding Converter={StaticResource windowStateCannotMaximize}, Property=Window.WindowState}"
                                            			Command="{x:Static shell:SystemCommands.MaximizeWindowCommand}" 
                                            			shell:WindowChrome.IsHitTestVisibleInChrome="True" Style="{DynamicResource MaxButtonStyle}" />
                                    <Button Content="Restore" 
                                            			Grid.Column="1"  Visibility="{TemplateBinding Converter={StaticResource windowStateCanMaximize}, Property=Window.WindowState}"
                                            			Command="{x:Static shell:SystemCommands.RestoreWindowCommand}" 
                                            			shell:WindowChrome.IsHitTestVisibleInChrome="True" Style="{DynamicResource RestoreButtonStyle}" />
                                    <Button Content="Close"
                                            			Grid.Column="2" 
                                                        Command="{x:Static shell:SystemCommands.CloseWindowCommand}" 
                                            			shell:WindowChrome.IsHitTestVisibleInChrome="True" Style="{DynamicResource CloseButtonStyle}"/>
                                    <!-- Margin="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowCaptionButtonsLocation, Converter={StaticResource CaptionButtonMarginConverter}}" -->
                                </Grid>
                            </Grid>

                            <Grid Grid.RowSpan="2" Panel.ZIndex="-1">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Border HorizontalAlignment="Left" 
                                        Background ="{Binding Path=Navigation.Background, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type WinChrome:SearchableNavigationWindow}}}">
                                    <Grid Width="{Binding ElementName=navigationPanel, Path=ActualWidth}" Margin="3"/>
                                </Border>
                                <TextBlock Grid.Column="1"
                                    Text="{Binding Content.Title, ElementName=PART_NavWinCP}" Foreground="Gray" Margin="3" FontSize="20pt" FontFamily="Segoe UI Light"
                                                               VerticalAlignment="Top" />
                            </Grid>
                            <DockPanel x:Name="mainDock"  LastChildFill="True" 
                                                       Margin="{Binding WindowResizeBorderThickness, Source={x:Static shell:SystemParameters2.Current}}" 
                                                       Grid.Row="1" Background="{x:Null}">
                                <!-- Content area ie where Pages go -->
                                <Grid DockPanel.Dock="Left">
                                    <ContentControl x:Name="navigationPanel" Content="{Binding Navigation, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type WinChrome:SearchableNavigationWindow}}}"/>
                                </Grid>

                                <Border DockPanel.Dock="Top">
                                    <ContentControl Content="{Binding Content.(UI:NavigationPage.Alert), ElementName=PART_NavWinCP}"/>
                                </Border>
                                <ScrollViewer VerticalScrollBarVisibility="{Binding Content.(UI:NavigationPage.VerticalScroll), ElementName=PART_NavWinCP}" >

                                    <AdornerDecorator >

                                        <Grid>
                                            <ContentPresenter Margin="12" 
                                                        				Content="{TemplateBinding ContentControl.Content}" 
                                                        				ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" 
                                                        				ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
                                                        				x:Name="PART_NavWinCP" ClipToBounds="True" />

                                            <ContentPresenter Content="{Binding GlobalContent, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type WinChrome:SearchableNavigationWindow}}}"/>

                                        </Grid>
                                    </AdornerDecorator>
                                </ScrollViewer>
                            </DockPanel>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="False"/>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <!-- Initial NavigationWindow dimensions -->
        <!-- <Setter Property="Width" Value="400" />
        <Setter Property="Height" Value="300" />-->

    </Style>
</ResourceDictionary>